package site.fsyj;

import lombok.extern.slf4j.Slf4j;
import site.fsyj.frame.SwingDemo;
import site.fsyj.service.MiHuYouTask;
import site.fsyj.util.ResourceUtil;

import java.util.Properties;

/**
 * @author fsyj on 2022/3/7
 */
@Slf4j
public class GenshinAutoSign {

    public static void main(String[] args) {
        checkCookie();
    }

    public static void checkCookie() {
        Properties configure = ResourceUtil.getConfigure("appConfig.properties");
        if (configure == null) {
            log.error("配置文件读取错误，系统结束");
            System.exit(-1);
        }
        String cookie = configure.getProperty("cookie");
        if (!cookie.contains("account_id") || !cookie.contains("cookie_token")) {
            SwingDemo.createGUI();
        } else {
            runTask();
        }
    }

    private static void runTask() {
        MiHuYouTask miHuYouTask = new MiHuYouTask();
        miHuYouTask.runTask();
        System.exit(0);
    }
}
